/**
 * @file:          motor.h
 * @brief:
 * @details:
 * @author:        wjh
 * @date created:  2025.07.23
 * @version:       1.0.0
 * @par copyright (c):
 *
 * @par history (desc):
 *   version:1.0.0, wjh, 2025.07.23,02:03:26
 */

#ifndef _MOTOR_H_
#define _MOTOR_H_

/* Include Files **************************************************************/
#include "stdint.h"

/* Macro Definition ***********************************************************/

/* Data Type Define ***********************************************************/
typedef struct Motor
{
    /* public data */
    float param_R;
    float param_L;
    float param_amp_gain;
    float param_R_sample;

    uint16_t adc_init_ok;

    float Ia; /* Unit: A */
    float Ib; /* Unit: A */
    float Ic; /* Unit: A */

    int16_t Ia_adc; /* Unit: adc */
    int16_t Ib_adc; /* Unit: adc */
    int16_t Ic_adc; /* Unit: adc */

    int16_t Ia_adc_raw; /* Unit: adc */
    int16_t Ib_adc_raw; /* Unit: adc */
    int16_t Ic_adc_raw; /* Unit: adc */

    int16_t Ia_adc_offset; /* Unit: adc */
    int16_t Ib_adc_offset; /* Unit: adc */
    int16_t Ic_adc_offset; /* Unit: adc */

    uint32_t adc_a_sum;
    uint32_t adc_b_sum;

    uint16_t en;
    float speed_rpm;

    /* private data */

    /* public method */
    void (*Init)(struct Motor *self);
    float (*Run)(struct Motor *self);

    /* private method */

} Motor;

/* Variable Declare ***********************************************************/

/* Function Declare ***********************************************************/
void Motor_Init(struct Motor *self);
float Motor_Run(struct Motor *self);

#endif